/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: stl_find.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月31日 星期四 10时40分32秒
***************************************************/

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <memory>

using namespace std;

class Student {
	string name;
	string study_id;
	int age;
	float math_score;
	public:
		Student(string _name) : name(_name)
		{
			
		}
		Student(string _name, int _age, float _math) : name(_name), age(_age), math_score(_math)
		{}
		bool operator==(const Student& stu)
		{
			cout << "call == override" << endl;
			return this->name == stu.name;
		}
		void show()
		{
			cout << "name:" << name << "," << age << "," << math_score << endl;
		}
		bool operator()(Student& stu)
		{
			return this->name == stu.name;
		}
};

int main(int argc,const char* argv[])
{
	vector<Student> group;
	
	group.push_back(Student("zhangsan", 21, 60.5));
	group.push_back(Student("lisi", 22, 70.5));
	group.push_back(Student("王二", 23, 60.5));
	
	//sort(group.begin(), group.end(), fun_obj);
	
	//auto it = find(group.begin(), group.end(), Student("王二", 0, 0.0));
	Student stu("王二");
	auto it = find_if(group.begin(), group.end(), stu);
	if (it != group.end()) {
		it->show();
	}
    return 0;
}
